<?php

// +----------------------------------------------------------------------
// | POS机回调
// +----------------------------------------------------------------------
// | Copyright (c) 2015-2024 http://www.yicmf.com, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 微尘 <yicmf@qq.com>
// +----------------------------------------------------------------------

namespace app\controller\api\notify;

use app\event\index\Task as TaskEvent;
use app\model\index\CreditcardProduct;
use think\facade\Log;

class Wei extends Common
{


    /**
     * 信用产品进度
     * 'Phone' => Phone,
     * 'Bank' => ,
     * 'InviterPhone' => ,
     * 'Name' => ,
     * 'IdCard' => ,
     * 'Amount' => ,
     */
    public function progress()
    {
        $data = $this->request->param();
        file_put_contents('credit.txt', time_format() . json_encode($data) . "\r\n\r\n", FILE_APPEND);
        $event = new TaskEvent();
        $rep = $event->third($data);
        if ($rep['code'] != 0) {
            Log::write($rep);
        }
        return 'success';
    }
    /**
     * 信用产品进度
     * 'Phone' => Phone,
     * 'Bank' => ,
     * 'InviterPhone' => ,
     * 'Name' => ,
     * 'IdCard' => ,
     * 'Amount' => ,
     */
    public function test()
    {
        $data = $this->request->param();
        $data = [
            'Amount' => '0',
            'Bank' => '华夏养老金开户',
            'InviterPhone' => '20200918018',
            'IdCard' => '410928199108076617',
            'Name' => '安忠凡',
            'Phone' => '18595639631',
            'Status' => '1',
            'controller' => 'wei',
            'action' => 'progress',];
//        file_put_contents('credit.txt', time_format() . json_encode($data) . "\r\n\r\n", FILE_APPEND);
        $event = new TaskEvent();
        $rep = $event->third($data);
        if ($rep['code'] != 0) {
            Log::write($rep);
        }
        return 'success';
    }

    /**
     * 上下架
     * 'Phone' => Phone,
     * 'Bank' => ,
     * 'InviterPhone' => ,
     * 'Name' => ,
     * 'IdCard' => ,
     * 'Amount' => ,
     */
    public function product()
    {
        $data = $this->request->param();
        file_put_contents('product.txt', time_format() . json_encode($data) . "\r\n\r\n", FILE_APPEND);
        $Product = CreditcardProduct::where('bankName', $data['Bank'])->find();
        if ($Product) {
            $Product['status'] = $data['status'];
            $Product->save();
        }
        return 'success';
    }
}
